﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DbHelp
{
    class Log
    {
        public static void Error(string msg)
        {
            Instance.LogError(msg);
        }
        static Log _Instance;
        static Log Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new Log();
                }
                return _Instance;
            }
        }

        string _logFile;

        private Log()
        {
            _logFile = System.AppDomain.CurrentDomain.BaseDirectory;
            _logFile += "//Log//ErrorDb.txt";

            if (!File.Exists(_logFile))
            {
                using (FileStream fileStream = File.Create(_logFile))
                {

                }
            }
        }

        void LogError(string msg)
        {
            try
            {
                File.AppendAllText(_logFile, System.DateTime.Now.ToString() + " : " + msg);
                File.AppendAllText(_logFile, string.Format("{0}", Environment.NewLine));
            }
            catch { }
            finally { }
        }
    }
}
